﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SAPbouiCOM;
using System.Collections;
using SAPbobsCOM;
using BoAddonBiz_FreightForwarder.UpLoad;
using System.Xml;
using System.Text.RegularExpressions;
using BoAddonBiz_FreightForwarder.BusinessBase;

namespace BoAddonBiz_FreightForwarder.Air
{
    [ControlB1Form(IsNew = true, FormType = B1FormTypes.ado_AVA_FF_Quote)]
    public class B1Form_Quote_Air : B1Form_Quote_Base
    {
        protected override string AVA_OQOT { get { return "@AVA_FF_OQOT"; } }
        protected override string AVA_QOT1 { get { return "@AVA_FF_QOT1"; } }
        protected override string AVA_QOT2 { get { return "@AVA_FF_QOT2"; } }
        protected override string AVA_QOT3 { get { return "@AVA_FF_QOT3"; } }
        protected override string AVA_QOT4 { get { return "@AVA_FF_QOT4"; } }
        protected override string AVA_QOT5 { get { return "@AVA_FF_QOT5"; } }
        protected override string AVA_QOT6 { get { return "@AVA_FF_QOT6"; } }
        protected override string AVA_QOT7 { get { return "@AVA_FF_QOT7"; } }
        protected override string Target_Delegate_Object { get { return "AVA_FF_Delegate"; } }
        protected override string Target_SalesOrder_Object { get { return "AVA_FF_SalesOrder"; } }

        public B1Form_Quote_Air()
        {
            this.frm_ItemEvent += new SAPBoAddon.IB1FormEvents.B1ItemEventEventHandler(B1Form_Quote_Air_frm_ItemEvent);
            this.frm_ChooseFormListEvent += new SAPBoAddon.IB1FormEvents.B1ChooseFormListEventEventHandler(B1Form_Quote_Air_frm_ChooseFormListEvent);
        }

        void B1Form_Quote_Air_frm_ChooseFormListEvent(SAPBoAddon.B1AddonBase.B1ChooseFormList pVal, ref bool BubbleEvent)
        {
            SAPbouiCOM.DBDataSource dbds = default(DBDataSource);
            Matrix mtx = default(Matrix);
            if (pVal.Before_Action)
            {

            }
            else
            {
                if (pVal.ChooseFromListUID == "CFL_AirLine_Fee")
                {

                    dbds = this.CurrentForm.DataSources.DBDataSources.Item(AVA_QOT1);
                    mtx = (SAPbouiCOM.Matrix)this.CurrentForm.Items.Item(pVal.ItemUID).Specific;
                    dbds.Offset = SAPBoAddon.B1Assistant.Matrix.GetdbDsOffset(mtx, pVal.Row, "col_f", dbds);
                    mtx.GetLineData(pVal.Row);
                    dbds.SetValue("U_CarrierCode", dbds.Offset, pVal.SelectedObjects.GetValue("U_AirLineCode", 0).ToString());
                    dbds.SetValue("U_CarrierName", dbds.Offset, pVal.SelectedObjects.GetValue("U_AirLineName", 0).ToString());
                    mtx.SetLineData(pVal.Row);
                }
                /*底价信息  航空公司信息*/
                else if (pVal.ChooseFromListUID == "CFL_AirLine_Low")
                {
                    dbds = this.CurrentForm.DataSources.DBDataSources.Item(AVA_QOT5);
                    mtx = (SAPbouiCOM.Matrix)this.CurrentForm.Items.Item(pVal.ItemUID).Specific;
                    dbds.Offset = SAPBoAddon.B1Assistant.Matrix.GetdbDsOffset(mtx, pVal.Row, "col_f", dbds);
                    mtx.GetLineData(pVal.Row);
                    dbds.SetValue("U_CarrierCode", dbds.Offset, pVal.SelectedObjects.GetValue("U_AirLineCode", 0).ToString());
                    dbds.SetValue("U_CarrierName", dbds.Offset, pVal.SelectedObjects.GetValue("U_AirLineName", 0).ToString());
                    mtx.SetLineData(pVal.Row);
                }
            }
        }

        void B1Form_Quote_Air_frm_ItemEvent(SAPBoAddon.B1AddonBase.B1ItemEvent pVal, ref bool BubbleEvent)
        {
            if (pVal.Before_Action)
            {

            }
            else
            {

            }
        }

        protected override void FormInfoSetting(SAPBoAddon.B1FormSetting FormSetting)
        {
            FormSetting.FormType = B1FormTypes.ado_AVA_FF_Quote;
            FormSetting.FormFileName = B1FormTypes.ado_AVA_FF_Quote.ToString() + "Form.srf";

            base.FormInfoSetting(FormSetting);
        }
    }
}
